package com.liang.common;

import com.google.common.collect.Maps;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * <h4>springboot-demo</h4>
 * <p></p>
 *
 * @author : liangben
 * @date : 2021-11-19 19:16
 **/
public class Constant {

    public static Map<String,String> getUserWriteHeadAlias(){
        Map<String,String> headAlias = Maps.newHashMap();
        headAlias.put("id","编号");
        headAlias.put("name","姓名");
        headAlias.put("age","年龄");
        return headAlias;
    }

    public static Map<String,String> getUserReadHeadAlias(){
        Map<String,String> headAlias = Maps.newHashMap();
        headAlias.put("编号","id");
        headAlias.put("姓名","name");
        headAlias.put("年龄","age");
        return headAlias;
    }

    /**
     * map key value 反转
     * @param map 参数
     * @return
     */
    public static Map<String,String> reversalMap(Map<String,String> map){
        return map.entrySet().stream()
                .collect(Collectors.toMap(
                        Map.Entry::getValue,
                        Map.Entry::getKey
                ));

    }
}
